package com.bohua.bohua.conf;

import org.beetl.core.GroupTemplate;
import org.beetl.ext.spring.AccessExpressionIfFunction;
import org.beetl.ext.spring.AccessUrlIfFunction;
import org.beetl.ext.spring.AuthenticationFunction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * beetl额外配置
 * 让beetl和security进行整合
 */
@Configuration
public class BeetlExtConfig {
    @Autowired
    GroupTemplate groupTemplate;

    @PostConstruct
    public  void config(){
        groupTemplate.registerFunction("auth",getAuth());
        groupTemplate.registerFunction("urlIf",getUrlIf());
        groupTemplate.registerFunction("expIf",getExpIf());

    }

    @Bean
    public AuthenticationFunction getAuth(){
        return  new AuthenticationFunction();
    }
    public AccessUrlIfFunction getUrlIf(){
        return  new AccessUrlIfFunction();
    }
    public AccessExpressionIfFunction getExpIf(){
        return  new AccessExpressionIfFunction();
    }

}
